<?php 
namespace app\common\model;
class MemberFans extends Common{
	protected $insert = ['addtime'=>SYS_TIME];
	public function set_status($data){
		return $this->where('userid', $data['touserid'])->where('touserid', $data['userid'])->setField('status', 1);
	}
	public function get_relat($userid, $touserid){
    	$status = $this->where('userid', $userid)->where('touserid', $touserid)->value('status');
    	if ($status === 0) {
			return 2;
		}elseif ($status === 1) {
			return 1;
		}
		$result = $this->where('userid', $touserid)->where('touserid', $userid)->value('status');
		if ($result === 0) {
			return 3;
		}elseif ($result === 1) {
			return 1;
		}
		return 0;
	}
	public function refuse($data){
		return $this->where('userid', $data['touserid'])->where('touserid', $data['userid'])->delete();
	}
}